home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / EMIL.ARJ / TESTHI.C < prev    next >
Text File  |  1991-05-07  |  2KB  |  72 lines

  1. /* testhi.c: test program for Extended Memory Interface Library
  2.  * Copyright (C) 1991 by Nicholas Wilt.
  3.  *
  4.  * This source file may be distributed freely as long as it is not
  5.  * separated from the rest of the Extended Memory Interface Library.
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include "hi.h"
  12.  
  13. main()
  14. {
  15.   int i;
  16.   unsigned int hand;
  17.   long cnt;
  18.   long test;
  19.  
  20.   printf("TESTHI: Extended Memory Interface Library Test Program\n");
  21.   printf("Copyright (C) 1991 by Nicholas Wilt.\n\n");
  22.   printf("Freely distributable as long as all parts of the distribution\n");
  23.   printf("are included.\n");
  24.   printf("Source available for hi.obj; see userman.doc for details.\n\n");
  25.   printf("Testing interface library...\n\n");
  26.  
  27.   if (! pinghi()) {
  28.     fprintf(stderr, "HIMEM not installed.\n");
  29.     exit(1);
  30.   }
  31.   /* Initialize library */
  32.   hiinit();
  33.  
  34.   /* Report contiguous and total amount of memory available */
  35.   printf("%lu contiguous bytes available\n", hicontig());
  36.   printf("%lu bytes available\n", himemavl());
  37.  
  38.   /* Allocate 4K of extended memory */
  39.   hand = himalloc(1024L * sizeof(long));
  40.   if (! hand) {
  41.     printf("Memory not available\n");
  42.     exit(-1);
  43.   }
  44.  
  45.   /* Count to 1024, putting the counts into extended memory */
  46.   for (cnt = 0; cnt < 1024L; cnt++) {
  47.     int ret = real2hi(hand, cnt << 2, &cnt, sizeof(long));
  48.     if (! ret) {
  49.       printf("real2hi returned 0 at cnt = %d\n", cnt);
  50.       exit(1);
  51.     }
  52.   }
  53.  
  54.   /* Read the counts back from extended memory, verifying */
  55.   /* that they agree with what was put there */
  56.   for (cnt = 0; cnt < 1024L; cnt++) {
  57.     int ret = hi2real(&test, hand, cnt << 2, sizeof(long));
  58.     if (! ret) {
  59.       printf("hi2real returned 0 at cnt = %d\n", cnt);
  60.       exit(1);
  61.     }
  62.     if (cnt != test)
  63.       printf("No good at cnt = %ld, test = %ld\n", cnt, test);
  64.   }
  65.  
  66.   /* Free the extended memory */
  67.   hifree(hand);
  68.  
  69.   printf("Extended Memory Interface Library tested okay\n");
  70.   return 0;
  71. }
  72.